<?php

/**
 * 
 * @export Loader
 */
class modelLoader extends AbstractLoader {
    
    private function getLocalModelPath() {
        return Loader::toSinglePath("{$this->getApp()}::{$this->getModuleName()}::models::", "");
    }


    private static function path() {
        return Loader::toSinglePath("models::", "");
    }

    public function setModuleName($moduleName) {
        parent::setModuleName($moduleName);
    }

    protected function resolveObject($name) {
        try {
            $this->checkFile($name, self::path());
        } catch (Exception $ex) {
            $this->checkFile($name, $this->getLocalModelPath());
        }

        $model = new $name();
        $serviceLoader = &ServiceLoader::instance();
        if($serviceLoader->getCurrentUser() == null){
            $serviceLoader->setCurrentUser($this->getCurrentUser());
        }
        $model->setServices($serviceLoader);

        return $model;
    }

}

?>
